package com.danciyixue.boot.client.program.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.danciyixue.boot.common.result.PageResult;
import com.danciyixue.boot.common.result.Result;
import com.danciyixue.boot.dcyx.model.query.ProgramsQuery;
import com.danciyixue.boot.dcyx.model.vo.ProgramsVO;
import com.danciyixue.boot.dcyx.model.vo.CurrentProgramVO;
import com.danciyixue.boot.dcyx.service.ProgramsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 教材控制器
 */
@Tag(name = "04. 教材", description = "教材")
@RestController
@RequestMapping("/api/client/v1/program")
@RequiredArgsConstructor
public class DcyxProgramController {

    private final ProgramsService programsService;

    /**
     * 获取教材数据
     */
    @GetMapping("/page")
    public PageResult<ProgramsVO> page(ProgramsQuery queryParams) {
        IPage<ProgramsVO> page = programsService.getProgramsPage(queryParams);
        return PageResult.success(page);
    }

    /**
     * 获取教材数据
     */
    @GetMapping("/current")
    @Operation(summary = "获取当前用户的教材数据")
    public Result<ProgramsVO> current() {
        ProgramsVO result = programsService.getCurrentProgramByUserToken();
        return Result.success(result);
    }
}
